<?php
header("Content-Type: application/vnd.ms-excel");
$filename = "RegistrosAlumnosEgresados_" . date('Y-m-d_h-i-s') . ".xls";
header("Content-Disposition: attachment; filename=\"$filename\"");
require_once("../Connections/conec.php");
?> 
<table>
	<tr>
		<td colspan="6">Universidad Diego Portales</td>
		<td>Fecha : <?php echo date('d-m-Y')?></td>
	</tr>
	<tr>
		<td colspan="6">Facultad de Derecho</td>
	</tr>
	<tr>
		<td colspan='7'> REGISTRO DE ALUMNOS EGRESADOS </td>
	</tr>
	<tr>
		<td></td>
		<td>Rut</td>
		<td>dv</td>
		<td>Apellido Paterno</td>
		<td>Apellido Materno</td>
		<td>Nombres</td>
		<td>Fecha Ingreso</td>
		<td>Fecha Egreso</td>
		<td>Nota Egreso</td>
	</tr>
<?php
$link = Conectarse();
$consulta = explode("\'", $_POST['consulta_alumnos_hc']);
$c = count($consulta);
$query;
for($i = 1; $i <= $c;$i++){
	$query .= $consulta[$i-1];
	if($i > 0 && $i < $c)
		$query .= "'";
}
//echo "POST: ".$_POST['consulta_alumnos_hc']."<br>";
//echo "query: ".$query;

//echo "POST: ".$_POST['consulta_alumnos_hc']."<br>";
//echo "query: ".$query;
$result = mysql_query($query, $link);
$i=1;
while($row=mysql_fetch_array($result)){
	echo "<tr>";
	echo "<td>".$i."</td>";
	echo "<td>".$row['RUT']."</td>";
	echo "<td>".$row['DV']."</td>";
	echo "<td>".$row['AP_PATERNO']."</td>";
	echo "<td>".$row['AP_MATERNO']."</td>";
	echo "<td>".$row['NOMBRES']."</td>";
	echo "<td>".$row['F_INGRESO']."</td>";
	echo "<td>".$row['F_EGRESO']."</td>";
	echo "<td>".$row['NOTA_EGRESO']."</td>";
	echo "</tr>";
	$i++;
}
?>
</table>